card_list = []


def create_id():
    """
    新建名片功能
    :return:
    """
    print()
    print("***新增名片***")
    name = input("请输入名字：")
    company = input("请输入公司名：")
    professor = input("请输入职业：")
    age = input("请输入年龄：")
    tel_num = input("请输入电话号码：")
    card_dict = {
        "姓名": name,
        "公司": company,
        "职业": professor,
        "年龄": age,
        "电话号码": tel_num
    }
    card_list.append(card_dict)
    print("." * 50)
    print(card_dict)
    print("录入成功！")
    input("按回车键继续……")
    print()


def show_all():
    """
    名片全部展示并可选择删除
    :return:
    """
    if card_list.__len__() == 0:
        print()
        input("名片信息为空，按下回车返回主菜单！")
        print()
        return
    print()
    print("***显示全部名片***")
    print()
    i = 0
    while i <= card_list.__len__() - 1:
        print(card_list[i])
        i += 1
    print("." * 50)
    choose_del = input("按回车继续，或者输入名字删除：")
    i = 0
    if choose_del != "":
        while i <= len(card_list) - 1:
            if card_list[i]["姓名"] == choose_del:
                del card_list[i]
                print("删除成功")
                print()
                input("按回车继续")
                print()
                show_all()
    else:
        print()
        return
    print()


def query_name():
    """
    根据名称查询名片并展示
    :return:
    """
    print()
    print("***查询***")
    print()
    query_by_name = input("请输入查询姓名：")
    i = 0
    flag = 0
    while i <= len(card_list) - 1:
        if card_list[i]["姓名"] == query_by_name:
            print(card_list[i])
            flag = 1
        i += 1
    if flag == 1:
        input("按回车继续")
        print()
    if flag == 0:
        print("没有查询到！")
        input("按回车继续")
        print()
